/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * frmPelayananResepKaryawan.java
 *
 * Created on Jan 25, 2012, 10:46:02 AM
 */
package SIMRS.Apotek.view;

import SIMRS.Apotek.sql.KoneksiDatabase;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import usu.widget.Form;
import java.util.Calendar;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
 *
 * @author yunniie
 */
public class frmPelayananResepKaryawan extends Form {
private DefaultTableModel model;

Connection koneksi=KoneksiDatabase.getKoneksi();
    /** Creates new form frmPelayananResepKaryawan */
    public frmPelayananResepKaryawan() {
        initComponents();
        
        model=new DefaultTableModel();
        tblPelayananResepKaryawan.setModel(model);
        model.addColumn("Kode Obat");
        model.addColumn("Nama Obat");
        model.addColumn("Jumlah");
        model.addColumn("Harga");
        
        txtHarga.setEnabled(false);
        
        Date tanggal = new Date();
        txtTanggalResep.setDate(tanggal);
        
        cmbNamaBarang.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from obat order by NamaBarang asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbNamaBarang.addItem(rs.getString("NamaBarang"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }

        
        cmbDokter.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from pegawai order by Nama asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbDokter.addItem(rs.getString("Nama"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }

        
        cmbPegawai.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from pegawai order by Nama asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbPegawai.addItem(rs.getString("Nama"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }
        
        
        cmbRuangan.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from ruangan order by NamaRuangan asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbRuangan.addItem(rs.getString("NamaRuangan"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }
        
        
        cmbUser.addItem("");
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select * from pegawai order by Nama asc");
         rs.beforeFirst();
         while(rs.next()){
             cmbUser.addItem(rs.getString("Nama"));
         }
         rs.close();
     }
     catch(SQLException ex)
     {
         System.out.println("Error : "+ex);
         }
        

        
        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/icon.png")).getImage());
        setTitle(".:: Form Pelayanan Resep Karyawan");
    }
    
   
    
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlForm1 = new SIMRS.Apotek.widget.PnlForm();
        label9 = new SIMRS.Apotek.widget.Label();
        pnlPelayananResepKaryawan = new javax.swing.JPanel();
        scrollPane1 = new SIMRS.Apotek.widget.ScrollPane();
        tblPelayananResepKaryawan = new SIMRS.Apotek.widget.Table();
        txtTotal = new SIMRS.Apotek.widget.TextBox();
        label8 = new SIMRS.Apotek.widget.Label();
        btnTambah = new SIMRS.Apotek.widget.button2();
        btnHapus = new SIMRS.Apotek.widget.button2();
        label10 = new SIMRS.Apotek.widget.Label();
        label12 = new SIMRS.Apotek.widget.Label();
        txtJumlah = new SIMRS.Apotek.widget.TextBox();
        label7 = new SIMRS.Apotek.widget.Label();
        txtTanggalResep = new com.toedter.calendar.JDateChooser();
        label3 = new SIMRS.Apotek.widget.Label();
        txtHarga = new SIMRS.Apotek.widget.TextBox();
        cmbNamaBarang = new javax.swing.JComboBox();
        kdBarang = new javax.swing.JTextField();
        btnSimpan = new SIMRS.Apotek.widget.button2();
        btnCetak = new SIMRS.Apotek.widget.button2();
        btnTutup = new SIMRS.Apotek.widget.button2();
        label13 = new SIMRS.Apotek.widget.Label();
        label11 = new SIMRS.Apotek.widget.Label();
        label1 = new SIMRS.Apotek.widget.Label();
        cmbDokter = new javax.swing.JComboBox();
        kdDokter = new javax.swing.JTextField();
        label2 = new SIMRS.Apotek.widget.Label();
        txtNoResep = new SIMRS.Apotek.widget.TextBox();
        cmbRuangan = new javax.swing.JComboBox();
        kdRuang = new javax.swing.JTextField();
        cmbPegawai = new javax.swing.JComboBox();
        kdPegawai = new javax.swing.JTextField();
        cmbUser = new javax.swing.JComboBox();
        label4 = new SIMRS.Apotek.widget.Label();
        idUser = new javax.swing.JTextField();

        setTitle("Form Pelayanan Resep Karyawan");
        setAnimationHide(usu.widget.constan.Animation.HIDE_TO_BOTTOM);
        setAnimationShow(usu.widget.constan.Animation.SHOW_FROM_TOP);
        setUndecorated(true);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        pnlForm1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(57, 190, 53), 3, true));
        pnlForm1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        label9.setText("Ruangan Kerja");
        pnlForm1.add(label9, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 140, 100, -1));

        pnlPelayananResepKaryawan.setBackground(new java.awt.Color(51, 51, 51));
        pnlPelayananResepKaryawan.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlPelayananResepKaryawan.setOpaque(false);
        pnlPelayananResepKaryawan.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        tblPelayananResepKaryawan.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        scrollPane1.setViewportView(tblPelayananResepKaryawan);

        pnlPelayananResepKaryawan.add(scrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 83, 640, 160));
        pnlPelayananResepKaryawan.add(txtTotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 250, 120, -1));

        label8.setText("Total");
        pnlPelayananResepKaryawan.add(label8, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 260, 30, 20));

        btnTambah.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_tambah.png"))); // NOI18N
        btnTambah.setText("Tambah");
        btnTambah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTambahActionPerformed(evt);
            }
        });
        pnlPelayananResepKaryawan.add(btnTambah, new org.netbeans.lib.awtextra.AbsoluteConstraints(37, 254, -1, -1));

        btnHapus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_hapus.png"))); // NOI18N
        btnHapus.setText("Hapus");
        btnHapus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHapusActionPerformed(evt);
            }
        });
        pnlPelayananResepKaryawan.add(btnHapus, new org.netbeans.lib.awtextra.AbsoluteConstraints(154, 254, -1, -1));

        label10.setText("Nama Obat");
        pnlPelayananResepKaryawan.add(label10, new org.netbeans.lib.awtextra.AbsoluteConstraints(22, 15, 70, 20));

        label12.setText("Jumlah");
        pnlPelayananResepKaryawan.add(label12, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 15, 54, 20));

        txtJumlah.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtJumlahActionPerformed(evt);
            }
        });
        pnlPelayananResepKaryawan.add(txtJumlah, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 41, 79, -1));

        label7.setText("Tanggal Resep");
        pnlPelayananResepKaryawan.add(label7, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 300, 90, 20));
        pnlPelayananResepKaryawan.add(txtTanggalResep, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 300, 130, -1));

        label3.setText("Harga");
        pnlPelayananResepKaryawan.add(label3, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 14, -1, 20));
        pnlPelayananResepKaryawan.add(txtHarga, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 40, 120, -1));

        cmbNamaBarang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbNamaBarangActionPerformed(evt);
            }
        });
        pnlPelayananResepKaryawan.add(cmbNamaBarang, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 170, -1));

        kdBarang.setForeground(new java.awt.Color(255, 255, 51));
        kdBarang.setBorder(null);
        kdBarang.setFocusable(false);
        kdBarang.setOpaque(false);
        pnlPelayananResepKaryawan.add(kdBarang, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 20, 100, 20));

        pnlForm1.add(pnlPelayananResepKaryawan, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 200, 670, 330));

        btnSimpan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_simpan.png"))); // NOI18N
        btnSimpan.setText("Simpan");
        btnSimpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSimpanActionPerformed(evt);
            }
        });
        pnlForm1.add(btnSimpan, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 540, -1, -1));

        btnCetak.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_cetak.png"))); // NOI18N
        btnCetak.setText("Cetak Resep");
        pnlForm1.add(btnCetak, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 540, -1, -1));

        btnTutup.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SIMRS/Apotek/gambar/bt_close.png"))); // NOI18N
        btnTutup.setText("Tutup");
        btnTutup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTutupActionPerformed(evt);
            }
        });
        pnlForm1.add(btnTutup, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 540, -1, -1));

        label13.setForeground(new java.awt.Color(255, 255, 255));
        label13.setText("Pelayanan Resep Karyawan");
        label13.setFont(new java.awt.Font("Tahoma", 1, 18));
        pnlForm1.add(label13, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, 400, -1));

        label11.setText("Nama Pegawai");
        pnlForm1.add(label11, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 140, 100, -1));

        label1.setText("Dokter");
        pnlForm1.add(label1, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 140, -1, -1));

        cmbDokter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbDokterActionPerformed(evt);
            }
        });
        pnlForm1.add(cmbDokter, new org.netbeans.lib.awtextra.AbsoluteConstraints(530, 160, 140, -1));

        kdDokter.setForeground(new java.awt.Color(255, 255, 51));
        kdDokter.setBorder(null);
        kdDokter.setFocusable(false);
        kdDokter.setOpaque(false);
        pnlForm1.add(kdDokter, new org.netbeans.lib.awtextra.AbsoluteConstraints(590, 140, 90, -1));

        label2.setText("No Resep");
        pnlForm1.add(label2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 140, -1, 20));
        pnlForm1.add(txtNoResep, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 160, 130, -1));

        cmbRuangan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbRuanganActionPerformed(evt);
            }
        });
        pnlForm1.add(cmbRuangan, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 160, 160, -1));

        kdRuang.setForeground(new java.awt.Color(255, 255, 51));
        kdRuang.setBorder(null);
        kdRuang.setFocusable(false);
        kdRuang.setOpaque(false);
        pnlForm1.add(kdRuang, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 140, 70, 20));

        cmbPegawai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbPegawaiActionPerformed(evt);
            }
        });
        pnlForm1.add(cmbPegawai, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 160, 160, -1));

        kdPegawai.setForeground(new java.awt.Color(255, 255, 51));
        kdPegawai.setBorder(null);
        kdPegawai.setFocusable(false);
        kdPegawai.setOpaque(false);
        pnlForm1.add(kdPegawai, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 140, 90, 20));

        cmbUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbUserActionPerformed(evt);
            }
        });
        pnlForm1.add(cmbUser, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 160, 120, -1));

        label4.setText("User");
        pnlForm1.add(label4, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 140, 40, -1));

        idUser.setForeground(new java.awt.Color(255, 255, 51));
        idUser.setBorder(null);
        idUser.setFocusable(false);
        idUser.setOpaque(false);
        pnlForm1.add(idUser, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 190, 100, -1));

        getContentPane().add(pnlForm1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 820, 590));

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-824)/2, (screenSize.height-597)/2, 824, 597);
    }// </editor-fold>//GEN-END:initComponents

private void btnTutupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTutupActionPerformed
    dispose();
}//GEN-LAST:event_btnTutupActionPerformed

private void txtJumlahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtJumlahActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txtJumlahActionPerformed

private void btnTambahActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTambahActionPerformed
// TODO add your handling code here:
    String []a=new String[4];
        a[0]=kdBarang.getText();
        a[1]=cmbNamaBarang.getSelectedItem().toString();
        a[2]=txtJumlah.getText();
        a[3]=txtHarga.getText();
        
     model.addRow(a);  
     hitung_total();
}//GEN-LAST:event_btnTambahActionPerformed

private void btnSimpanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSimpanActionPerformed
// TODO add your handling code here:
     Connection c = KoneksiDatabase.getKoneksi();
    if (tblPelayananResepKaryawan.getRowCount() == 0) {
        JOptionPane.showMessageDialog(this, "Data Masih Kosong!");
    } else {
        try {
            String noResep = txtNoResep.getText();
            String Ruang = kdRuang.getText();
            SimpleDateFormat Format = new SimpleDateFormat("yyyy-MM-dd");
            String tanggal = Format.format(txtTanggalResep.getDate());
            String noDokter= kdDokter.getText();
            String Pegawai= kdPegawai.getText();
            String user=idUser.getText();
            String tot = txtTotal.getText();
            
            
            Statement stm = c.createStatement();
            String sql = "insert into pembeliobatkaryawan values('" + noResep + "','" + Pegawai + "')";
            String sql2 = "insert into resepobat values('" + noResep + "','" +tanggal + "','" +noDokter + "','" +Ruang + "','"+user +"')";
/*            CallableStatement resepobat=c.prepareCall("{call ResepObat_Add(?,?,?,?,?)}");
            resepobat.setString(1, txtNoResep.getText());
            resepobat.setString(2, txtTanggalResep.getDateFormatString());
            resepobat.setString(3, cmbDokter.getSelectedItem().toString());
            resepobat.setString(4, cmbRuangan.getSelectedItem().toString());
            resepobat.setString(5, cmbUser.getSelectedItem().toString());
            
            
            ResultSet rs=resepobat.executeQuery();*/

            stm.executeUpdate(sql);
            stm.executeUpdate(sql2);

            for (int i = 0; i < tblPelayananResepKaryawan.getRowCount(); i++) {

                    String barang = (String) tblPelayananResepKaryawan.getValueAt(i, 0);
                    String jml= (String) tblPelayananResepKaryawan.getValueAt(i, 2);
                    String harga= (String) tblPelayananResepKaryawan.getValueAt(i, 3);
                    

                 String sql1 = "insert into transaksireseppegawai values('" + noResep + "','" + barang + "','" + jml + "','" + Pegawai + "','" + harga + "','" + tot + "')";

                  stm.executeUpdate(sql1);

                }
            
            JOptionPane.showMessageDialog(this, "Data Berhasil Disimpan");
           
            txtNoResep.setText("");
            txtJumlah.setText("");
            txtHarga.setText("");
            txtTotal.setText("");
            kdBarang.setText("");
            kdRuang.setText("");
            kdDokter.setText("");
            kdPegawai.setText("");
            idUser.setText("");
            cmbNamaBarang.setSelectedItem("");
            cmbPegawai.setSelectedItem("");
            cmbRuangan.setSelectedItem("");
            cmbDokter.setSelectedItem("");
            cmbUser.setSelectedItem("");
            
            
            
        } catch (SQLException e) {
            System.out.println("Error : " + e);
            JOptionPane.showMessageDialog(this, "Data gagal disimpan");
        }
    }
}//GEN-LAST:event_btnSimpanActionPerformed

private void btnHapusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHapusActionPerformed
// TODO add your handling code here:
    int row=tblPelayananResepKaryawan.getSelectedRow();
    model.removeRow(row);
}//GEN-LAST:event_btnHapusActionPerformed

private void cmbRuanganActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbRuanganActionPerformed
// TODO add your handling code here:
    try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select KdRuangan from ruangan where NamaRuangan= '"+cmbRuangan.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             kdRuang.setText(rs.getString(1).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
}//GEN-LAST:event_cmbRuanganActionPerformed

private void cmbDokterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbDokterActionPerformed
// TODO add your handling code here:
    try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select IdPegawai from pegawai where Nama= '"+cmbDokter.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             kdDokter.setText(rs.getString(1).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
}//GEN-LAST:event_cmbDokterActionPerformed

private void cmbNamaBarangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbNamaBarangActionPerformed
// TODO add your handling code here:
    try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("SELECT obat.KdBarang, hargabarangmedis.HargaNetto1 FROM obat JOIN hargabarangmedis ON (obat.KdBarang=hargabarangmedis.KdBarang) where obat.NamaBarang= '"+cmbNamaBarang.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             kdBarang.setText(rs.getString(1).trim());
             txtHarga.setText(rs.getString(2).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
}//GEN-LAST:event_cmbNamaBarangActionPerformed

private void cmbPegawaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbPegawaiActionPerformed
// TODO add your handling code here:
    try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select IdPegawai from pegawai where Nama= '"+cmbPegawai.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             kdPegawai.setText(rs.getString(1).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
}//GEN-LAST:event_cmbPegawaiActionPerformed

    private void cmbUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbUserActionPerformed
        // TODO add your handling code here:
        try{
         Statement stm = koneksi.createStatement();
         ResultSet rs = stm.executeQuery("select IdPegawai from pegawai where Nama= '"+cmbUser.getSelectedItem().toString()+"'");
         rs.beforeFirst();
         while(rs.next()){
             idUser.setText(rs.getString(1).trim());
         }
         rs.close();
         }
         catch(SQLException ex)
         {
             System.out.println("Error : "+ex);
             }
    }//GEN-LAST:event_cmbUserActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private SIMRS.Apotek.widget.button2 btnCetak;
    private SIMRS.Apotek.widget.button2 btnHapus;
    private SIMRS.Apotek.widget.button2 btnSimpan;
    private SIMRS.Apotek.widget.button2 btnTambah;
    private SIMRS.Apotek.widget.button2 btnTutup;
    private javax.swing.JComboBox cmbDokter;
    private javax.swing.JComboBox cmbNamaBarang;
    private javax.swing.JComboBox cmbPegawai;
    private javax.swing.JComboBox cmbRuangan;
    private javax.swing.JComboBox cmbUser;
    private javax.swing.JTextField idUser;
    private javax.swing.JTextField kdBarang;
    private javax.swing.JTextField kdDokter;
    private javax.swing.JTextField kdPegawai;
    private javax.swing.JTextField kdRuang;
    private SIMRS.Apotek.widget.Label label1;
    private SIMRS.Apotek.widget.Label label10;
    private SIMRS.Apotek.widget.Label label11;
    private SIMRS.Apotek.widget.Label label12;
    private SIMRS.Apotek.widget.Label label13;
    private SIMRS.Apotek.widget.Label label2;
    private SIMRS.Apotek.widget.Label label3;
    private SIMRS.Apotek.widget.Label label4;
    private SIMRS.Apotek.widget.Label label7;
    private SIMRS.Apotek.widget.Label label8;
    private SIMRS.Apotek.widget.Label label9;
    private SIMRS.Apotek.widget.PnlForm pnlForm1;
    private javax.swing.JPanel pnlPelayananResepKaryawan;
    private SIMRS.Apotek.widget.ScrollPane scrollPane1;
    private SIMRS.Apotek.widget.Table tblPelayananResepKaryawan;
    private SIMRS.Apotek.widget.TextBox txtHarga;
    private SIMRS.Apotek.widget.TextBox txtJumlah;
    private SIMRS.Apotek.widget.TextBox txtNoResep;
    private com.toedter.calendar.JDateChooser txtTanggalResep;
    private SIMRS.Apotek.widget.TextBox txtTotal;
    // End of variables declaration//GEN-END:variables

    public void isiText(String noResep, String pegawai, String dokter, String user, String ruang, String nmBarang, String jmlh, String harga, Date a, String tot){
  txtNoResep.setText(noResep);
  cmbPegawai.setSelectedItem(pegawai);
  cmbDokter.setSelectedItem(dokter);
  cmbRuangan.setSelectedItem(ruang);
  cmbUser.setSelectedItem(user);
  cmbNamaBarang.setSelectedItem(nmBarang);
  txtJumlah.setText(jmlh);
  txtHarga.setText(harga);
  txtTanggalResep.setDate(a);

  
}   
    
    private void hitung_total()
    {
       
        int jml, hrga, xtot, total;
      
        total=0;
        xtot=0;
        jml = Integer.parseInt(txtJumlah.getText());
        hrga=Integer.parseInt(txtHarga.getText());
        xtot = jml*hrga;
      //  String xjml = Integer.toString(xtot);
      //  txtTotal.setText(xjml);
        for (int i = 0; i < tblPelayananResepKaryawan.getRowCount(); i++) {
            
            total=total+xtot;
            String Total=Integer.toString(total);
            txtTotal.setText(Total);
            tblPelayananResepKaryawan.getCellRenderer(jml, 3);
        }
        
        
    }

}
